package aplicacao.movel.locais;

import java.io.ObjectOutputStream.PutField;

import br.usp.fsi.entity.Local;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import aplicacao.movel.ActivityGenerica;
import aplicacao.movel.R;
import aplicacao.movel.R.botao;
import aplicacao.movel.R.layout;

public class DetalhesLocalActivity extends ActivityGenerica{
	
	private Button editaLocal;
	private Intent editarLocal;
	private TextView nomeLocal;
	private TextView enderecoLocal;
	private TextView nroLocal;
	private TextView cepLocal;
	private Bundle localDet;
	
	protected void telaDetalhesLocal() {
		setContentView(R.layout.detalhesdolocal);
		
		
		nomeLocal = (TextView) findViewById(R.id.textNomeEdit);
		enderecoLocal = (TextView) findViewById(R.id.textEnderecoEdit);
		nroLocal = (TextView) findViewById(R.id.textNumeroEdit);
		cepLocal = (TextView) findViewById(R.id.textcepEdit);

		localDet = getIntent().getExtras();
		final Local loc = (Local)localDet.get("localAEditar");
		if (localDet != null){
		nomeLocal.setText(loc.getNome());
		enderecoLocal.setText(loc.getEndereco());
		nroLocal.setText(new Integer(loc.getNumero()).toString());
		cepLocal.setText(loc.getCep());
		}
		
		editaLocal = (Button) findViewById(R.botao.bteditar_detlocal);
		editarLocal = new Intent (this, EditaCriaLocalActivity.class);
		
		editaLocal.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Bundle localDetalhes  = new Bundle();
				localDetalhes.putSerializable("localAEditar", loc);
				editarLocal.putExtras(localDetalhes);
				startActivity(editarLocal);
			}
		});
	}
	
	 @Override
	    public void onCreate (Bundle icile){
	    	super.onCreate(icile);
	    	telaDetalhesLocal();
	    }


}
